<style>
.layui-icon-close{color:red;font-weight: bold;}
.layui-icon-ok{color:#5FB878;font-weight: bold;}
</style>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	
	<!-- END RIBBON -->
	<div class="content">
		<div class="panel panel-default panel-intro">
			<div class="panel-heading">
				<div class="panel-lead">
					<em>CMS - 【{$title}】 - 内容管理</em>
					...
				</div>
			</div>
			<div class="panel-body">
				<div id="myTabContent" class="tab-content">
					<div class="tab-pane fade active in" id="one">
						<div class="widget-body no-padding">
							<div class="bootstrap-table">
								
								<div class="fixed-table-toolbar">
									<div class="bs-bars pull-left">
										<div id="toolbar" class="toolbar">
											<a href="javascript:window.location.reload();" class="btn btn-primary btn-refresh" title="刷新">
												<i class="fa fa-refresh"></i>
											</a>
											{if condition="$adminController->vif('article','add')"}
												<a href="{:url('add', ['pid'=>$pid, 'im_id'=>$im_id])}" class="btn btn-success btn-add" title="添加"><i class="fa fa-plus"></i> 添加</a>
											{/if}
										</div>
									</div>
									<div class="columns columns-right btn-group pull-right">
										<div class="keep-open btn-group" title="列">
											<button type="button" aria-label="columns" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
												<i class="glyphicon glyphicon-th icon-th"></i>
												<span class="caret"></span>
											</button>
												<ul class="dropdown-menu" id="table_menu">
												
											</ul>
										</div>
									</div>
								</div>
								<div class="fixed-table-container" style="padding-bottom: 0px;">
									<div class="fixed-table-body">
										<table id="table" class="table table-striped table-bordered table-hover" width="100%">
											<thead>
												<tr>
													{foreach name="field" item="v"}
													<th data-status="1"><div class="th-inner">{$v.if_title}</div></th>
													{/foreach}
													<th data-status="1" width="80"><div class="th-inner">状态</div></th>
													<th data-status="1" width="170"><div class="th-inner">添加时间</div></th>
													<th data-status="1" width="120"><div class="th-inner">操作</div></th>
												</tr>
											</thead>
											
											<tbody id="content-main">
													{foreach name="list" item="v"}
													<tr class="del-{$v.id}">
														{foreach name="field" item="val"}
															{if condition="$val['if_type'] == 'image'"}
															<td align="center"><img width="50" src="{php} echo $v[$val['if_name']]; {/php}"></td>
															{else /}
															<td align="center">{php} echo $v[$val['if_name']]; {/php}</td>
															{/if}
														{/foreach}
														<td align="center">
															{if condition="$v.status == 1"}
																<a href="javascript:status('{:url('status', ['pid'=>$v['id'], 'status'=>0, 'im_id'=>$im_id])}');">
																	<i class="layui-icon layui-icon-ok">&#xe605;</i>
																</a>
															{else /}
																<a href="javascript:status('{:url('status', ['pid'=>$v['id'], 'status'=>1, 'im_id'=>$im_id])}');">
																	<i class="layui-icon layui-icon-close">&#x1006;</i>
																</a>
															{/if}
														</td>
														<td align="center">{$v.time}</td>
														<td style="text-align: center; vertical-align: middle; ">
															{if condition="$adminController->vif('article','upd')"}
															<a href="{:url('upd', ['pid'=>$pid, 'id'=>$v['id'], 'im_id'=>$im_id])}" class="btn btn-xs btn-success btn-editone" title="编辑">
																<i class="fa fa-pencil"></i>
															</a>
															{/if}
															{if condition="$adminController->vif('article','delete')"}
															<button data-id="{$v.id}" data-pid="{$im_id}" onclick="return del(this)" class="btn btn-xs btn-danger btn-delone del_menu" title="删除">
																<i class="fa fa-trash"></i>
															</button>
															{/if}
														</td>
													</tr>
													{/foreach}
											</tbody>
										</table>
									</div>
									<div class="fixed-table-pagination" style="display: block;">
										<div class="pull-left pagination-detail">
											{$page}
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>


<script>

layui.use(['form'], function(){
  var form = layui.form;
});
// 删除
function del(_this) {
	var id = $(_this).attr('data-id');
	var pid = $(_this).attr('data-pid');
	$.ajax({
		type: 'post',
		data: {'id':id, 'im_id':pid},
		url: '{:url("delete")}',
		success: function(data) {
			var array = eval('('+data+')');
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		}
	});
}
// 切换状态
function status(href) {
	$.ajax({
		type: 'post',
		data: {},
		url: href,
		success: function(data) {
			var array = eval('('+data+')');
			if (array['code'] == '01') {
				$.thinkmimi({Content : array['msg'], Type:2, Align:'right', OutTime:2000});
			} else {
				$.thinkmimi({Content : array['msg'], Type:1, Align:'right', OutTime:2000});
				window.setTimeout(function(){
					window.location.reload();
				}, 700);
			}
		}
	});
}

</script>
